package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("ajax")
@CrossOrigin
public class ajaxController {
    @Autowired
    private UserService userService;
    @GetMapping("findById")
    public User findById(Integer id){
        return userService.findById(id);
    }
    @GetMapping("findByAS")
    public List<User> findByAS(User user){
        return userService.findByAS(user);
    }
    @GetMapping("user/{name}/{sex}")
    public User findByNS(User user){
        return userService.findByNS(user);
    }
    @PostMapping("saveUser")
    public String saveUser(@RequestBody User user){
        userService.saveUser(user);
        return "保存成功";
    }
}
